const path = require('path');
var prod = process.env.NODE_ENV
var config = {}
if (prod === 'test') {
  config = {
    h5BasePath: 'https://m.hhlysport.com/api',
    webOpenBasePath: 'https://open.hhlysport.com'
  }
} else if (prod === 'preannouncement') {
  config = {
    h5BasePath: 'https://yum.hhlyty.cn/api',
    webOpenBasePath: 'https://yuopen.hhlyty.cn'
  }
} else if (prod === 'production') {
  config = {
    h5BasePath: 'https://m.oooseed.com/api',
    webOpenBasePath: 'https://open.oooseed.com'
  }
} else {
  config = {
    h5BasePath: 'http://m.htxk.kf/api',
    webOpenBasePath: 'http://183.62.174.53:9817'
  }
}
console.log(config.h5BasePath)

module.exports = {
  wpyExt: '.wpy',
  build: {
    web: {
      htmlTemplate: path.join('src', 'index.template.html'),
      htmlOutput: path.join('web', 'index.html'),
      jsOutput: path.join('web', 'index.js')
    }
  },
  appConfig: config,
  resolve: {
    alias: {
      '@': path.join(__dirname, 'src')
    },
    modules: ['node_modules']
  },
  eslint: true,
  compilers: {
    // less: {
    //   compress: true
    // },
    sass: {
      outputStyle: 'compressed'
    },
    babel: {
      sourceMap: false,
      presets: [
        'env'
      ],
      plugins: [
        'transform-class-properties',
        'transform-decorators-legacy',
        'transform-object-rest-spread',
        'transform-export-extensions',
        "syntax-export-extensions"
      ]
    }
  },
  plugins: {
  }
}

if (prod === 'production' || prod === 'preannouncement') {

  delete module.exports.compilers.babel.sourcesMap;
  // 压缩sass
  module.exports.compilers['sass'] = {outputStyle: 'compressed'}

  // 压缩less
  // module.exports.compilers['less'] = {compress: true}

  // 压缩js
  module.exports.plugins = {
    uglifyjs: {
      filter: /\.js$/,
      config: {
      }
    },
    // imagemin: {
    //   filter: /\.(jpg|png|jpeg)$/,
    //   config: {
    //     jpg: {
    //       quality: 80
    //     },
    //     png: {
    //       quality: 80
    //     }
    //   }
    // }
  }
}
